<template>
  <!--  <el-button type="success" round @click="addEarthquakeVisible=true"  style="margin: 5px" icon="el-icon-plus">添加地震</el-button>-->
  <el-dialog
      v-model="administratorEditVisible"
      title="个人信息"
      width="50%"
  >
    <el-form
        ref="form"
        :model="form"
        label-width="120px"
        label-position="top"
    >

      <el-form-item label="当前账号" prop="email">
        <el-input placeholder="不可更改" disabled type="text" v-model="form.email"></el-input>
      </el-form-item>
      <el-form-item label="原密码" prop="oldPassword">
        <el-input placeholder="原密码" type="text" v-model="form.oldPassword"></el-input>
      </el-form-item>
      <el-form-item label="新密码" prop="newPasswordOne">
        <el-input placeholder="请输入客户姓名" type="text" v-model="form.newPasswordOne"></el-input>
      </el-form-item>
      <el-form-item label="确认新密码" prop="newPasswordTwo">
        <el-input placeholder="请再次输入新密码" type="text" v-model="form.newPasswordTwo"></el-input>
      </el-form-item>
      <el-form-item style="text-align: center;">
        <el-button
            type="primary"
            @click="onSubmit"
        >
          确定
        </el-button>
        <el-button @click="administratorEditVisible=false">
          取消
        </el-button>
      </el-form-item>
    </el-form>
  </el-dialog>
</template>

<script>
import {Select} from "@element-plus/icons-vue";
import {myElError} from "@/js/elmentUtil";
import {changePasswordApi} from "@/axios/api/Administrator";

export default {
  name: "AdministratorEdit",
  components: {Select},
  data() {
    return {
      sexes: ["男", "女"],
      administratorEditVisible: false,
      form: {
        email: '',
        oldPassword: '',
        newPasswordOne: '',
        newPasswordTwo: ''
      },
    }
  },
  methods: {
    onSubmit() {
      if (this.form.newPasswordTwo === "" || this.form.newPasswordOne === "") {
        myElError("密码为空!")
        return
      }
      if (this.form.newPasswordOne !== this.form.newPasswordTwo) {
        myElError("俩次密码不一致!")
        return
      }
      const params = {
        email: this.form.email,
        oldPassword: this.form.oldPassword,
        newPasswordOne: this.form.newPasswordOne
      }
      changePasswordApi(params).then().catch(err => {
      })

    },
    updateAdministrator(data) {
      // this.administratorEditVisible=false
    }
  }
}
</script>

<style scoped>

</style>
  